package com.corn.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : Jim Wu
 * @version 1.0
 * @function :
 * @since : 2021/4/6 16:31
 */

@RestController
public class TestController {

    @GetMapping("/test")
    public String test() {
        return "hello security!";
    }

    @GetMapping("/hello")
    public String hello() {
        return "hello world!";
    }

    @GetMapping("hasRole")
    @PreAuthorize("hasRole('admin')")
    public String hasRole() {
        return "hasRole";
    }

    @GetMapping("hasAuthority")
    @PreAuthorize("hasAuthority('add')")
    public String hasAuthority() {
        return "hasAuthority";
    }
}
